package org.NooLab.nativebrowser.app.controller;

import org.NooLab.nativebrowser.app.controller.parser.HTMLParser;
import org.NooLab.nativebrowser.app.controller.parser.Page;
import org.NooLab.nativebrowser.app.controller.parser.PageIntf;
import org.NooLab.nativebrowser.components.WebBrowserAppMainIntf;




public class HtmlConsumer implements HtmlConsumerIntf{

	WebBrowserAppMainIntf webBrowserApp ;
	private HTMLParser domparser;

	
	private PageIntf page;
	
	// ========================================================================
	public HtmlConsumer(WebBrowserAppMainIntf app) {
		
		webBrowserApp = app;
		
		
	}
	// ========================================================================
	
	
	@Override
	public void parseHtml(String pageStr, String contextURL) {
		// 
		domparser = new HTMLParser();
		
		domparser.parse(pageStr, contextURL);
		
		page = new Page();
	}


	@Override
	public void parseHtml(String pageStr) {
		
		page = new Page();
		
		domparser = new HTMLParser(page);
		domparser.parse(pageStr, "") ;
		
		
	}


	@Override
	public void parseHtml(PageIntf page) {
		// 
		
		this.page = page;
		domparser = new HTMLParser(page);
		domparser.parse() ;

		// not here:  page.setText("");
		// this has been already done inside the wrapping parser object!
	}


	@Override
	public PageIntf getPage() {
		// 
		return page;
	}

}
